<?php
class Model_Admin_Tag extends Model{

    public function getInfo($username,$caption,$offset,$pageSize){

        $sql="select count(1)total
             from tag t
             left join site_user s on s.site_userid=t.userid
             where t.isdeleted<>'1'
             and s.fullname like '%$username%'
             and t.caption like '%$caption%'";

        $total=DB::query(Database::SELECT,$sql)->execute()->get("total");

        $sql="select t.tagid id,t.caption,t.createdon
             from tag t
             left join site_user s on s.site_userid=t.userid
             where t.isdeleted<>'1'
             and t.caption like '%$caption%'
             and s.fullname like '%$username%'
             order by t.createdon desc limit $offset,$pageSize";

        $data=DB::query(Database::SELECT,$sql)->execute()->as_array();

        return array("total"=>$total,"rows"=>$data);
    }
}